package org.example.ReferenceType;

import java.lang.ref.WeakReference;

/**
 * WeakReference is a reference that does not prevent the object from being
 * 弱引用，
 * 一次性
 */
public class T02_WeakReference {
    public static void main(String[] args) {
        WeakReference<M> m = new WeakReference<>(new M());
        System.out.println(m.get());
        System.gc();
        System.out.println(m.get());

        ThreadLocal<M> tl = new ThreadLocal<>();
        tl.set(new M());
        tl.remove();
    }
}
